<template>
  <div>
      <myhead></myhead>
      <van-row>
        <van-col span="3"> <navigation></navigation>  </van-col>
        <van-col span="21"> 
            <br>
             组织名称：<input type="text"> <van-button>查询</van-button>  <van-button>重置</van-button>  <br>
             <br>
             <van-button>新增</van-button>  <van-button @click="download">导出</van-button>  
                  <van-uploader :after-read="uploader">
                    <van-uploader>
                        <van-button icon="plus" type="primary">导入文件</van-button>
                    </van-uploader>
                    </van-uploader>
             <br> <br>
            <table width="800px">
                <tr>
                    <td>组织名称</td>
                    <td>组织编码</td>
                    <td>组织类型</td>
                    <td>组织排序</td>
                    <td>操作</td>
                    
                </tr>
                <tr>     
                  <td><tree @changepid="getpid"></tree></td>  
                  <td>
                    <van-button @click="ad" v-if="bun">添加下级</van-button>
                    <div v-if="msg">
                        <van-cell-group>
                          <van-field label="输入公司名称或部门名称" v-model="name"/>
                          <van-field label="输入公司名称或部门编号" v-model="code"/>
                        
                        </van-cell-group>
                        <van-button @click="add">添加下级</van-button>
                    </div>
                  </td>
                </tr>
                
            </table>
            
        </van-col>
        
      </van-row>
      
  </div>
</template>

<script>
import Myhead from './comm/myhead.vue'
import navigation from './comm/left.vue'
import axios from 'axios'
import tree from './tree.vue'

// import axios from '../http/axios'

export default {
    data(){
      return{
        message:[],
        pid:0,
        msg:false,
        bun:true,
        name:'',
        code:''
       
      }
    },
    components:{
        Myhead,
        navigation,
        tree,
    },
    methods:{
      add(){
        axios.post('/deptlist',{'name':this.name,'coding':this.pid,'code':this.code}).then(res=>{
          console.log(this.pid);

          console.log(res);
        })
      },
      ad(){
        this.msg = true
        this.bun = false
      },  
      uploader(file) {
        let formData = new FormData()
        formData.append('file', file.file)
        axios({method: 'post',url: '/upload', data: formData}).then(res => {
                console.log(res)
        })
    },
      download(){
        axios({mounted:'post',url:'download'}).then(res=>{
          console.log(res);
        })
      },
      getpid(id){
        this.pid = id
        // alert(id)
      }
      

    },
    
}
</script>

<style>

</style>


